﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace UtilZ.Dotnet.Ex.Communication.Net.MQBase
{
    /// <summary>
    /// 订阅信息基类
    /// </summary>
    public class MQSubscribInfo : IMQSubscribInfo
    {
        /// <summary>
        /// 消息输出事件
        /// </summary>
        public event EventHandler<MQMessageOutputArgs> MessageOutput;

        /// <summary>
        /// 触发消息输出事件
        /// </summary>
        /// <param name="mqMessage">消息</param>
        public void OnRaiseMessageOutput(IMQMessage mqMessage)
        {
            var handler = this.MessageOutput;
            if (handler != null)
            {
                handler(this, new MQMessageOutputArgs(this, mqMessage));
            }
        }

        /// <summary>
        /// 签收模式
        /// </summary>
        public MQSignMode SignMode { get; set; } = MQSignMode.Auto;

        /// <summary>
        /// 分发模式[true:主题;false:队列]
        /// </summary>
        public bool DispatchMode { get; set; } = true;

        /// <summary>
        /// 主题
        /// </summary>
        public string Topic { get; set; }

        /// <summary>
        /// 订阅标识,非空为持久化订阅,为空则为非持久化订阅
        /// </summary>
        public string ID { get; set; } = string.Empty;

        /// <summary>
        /// 消息选择器字符串
        /// </summary>
        public string Selector { get; set; } = string.Empty;

        /// <summary>
        /// Tag
        /// </summary>
        public object Tag { get; set; }



        /// <summary>
        /// 构造函数
        /// </summary>
        public MQSubscribInfo()
        {

        }
    }
}
